<?php

namespace App\Http\Requests\Common\CatData\App;

use App\Http\Requests\Request;
/**
 * @author  吴珊珊
 * @date 2017/11/8 
 * 无用模板
 */

class TplRequest extends Request
{

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        switch ($this->method()) {
            case 'GET':
            case 'DELETE':
                {
                    return [];
                }
            // Crate
            case 'POST':
                {
                    return [
                        // 'tpl_no'      => 'required|max:100|unique:tpls,tpl_no',
                        'name'        => 'required|max:100',
                        'title'       => 'max:100',
                        'subtitle'    => 'max:100',
                        'snapshot_id' => 'required', // |max:200
                        'short_desc'  => 'required|max:100',
                    ];
                }
            // UPDATE
            case 'PUT':
            case 'PATCH':
                {
                    $id = $this->route('tpls');
                    return [
                        // 'tpl_no'      => 'required|max:100|unique:tpls,tpl_no,' . $id,
                        'name'        => 'required|max:100',
                        'title'       => 'max:100',
                        'subtitle'    => 'max:100',
                        'snapshot_id' => 'required', //|max:200
                        'short_desc'  => 'required|max:100',
                    ];
                }
            default:
                break;
        }
    }
}
